//
//  StudentCommentCell.m
//  jiyujiaProgram
//
//  Created by Jame on 15/11/22.
//  Copyright © 2015年 中良 赵. All rights reserved.
//

#import "StudentCommentCell.h"
#import "CommentModel.h"

@implementation StudentCommentCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setCellWithModel:(NSArray *)model WithIndexPath:(NSIndexPath *)indexPath WithSegment:(NSInteger)segment
{
    //菅帅博
    CommentData *data = model[indexPath.row];
    
    CGFloat score = ([data.teaching_attitude integerValue] + [data.dressing integerValue] + [data.describe_score integerValue])/3;

    switch (segment) {
        case 0:
        {
            self.nameLabel.text = data.mName;
            self.commentLabel.text = data.content;
        }
            break;
            
        default:
            break;
    }

    self.starView.starImage = ECIMAGENAME(@"star_gray.png");
    self.starView.starHighlightedImage = ECIMAGENAME(@"star_orange.png");
    self.starView.maxRating = 5.0;
    self.starView.horizontalMargin = 12.0;
    self.starView.editable = NO;
    self.starView.displayMode = EDStarRatingDisplayFull;
    self.starView.backgroundColor = [UIColor clearColor];

    switch (([data.teaching_attitude integerValue] + [data.dressing integerValue] + [data.describe_score integerValue])/3) {
        case 0:
        {
            self.typeLabel.text = @"差评";
            self.starView.rating = score;
        }
            break;
        case 1:
        {
            self.typeLabel.text = @"差评";
            self.starView.rating = score;
        }
            break;
        case 2:
        {
            self.typeLabel.text = @"中评";
            self.starView.rating = score;
        }
            break;
        case 3:
        {
            self.typeLabel.text = @"中评";
            self.starView.rating = score;
        }
            break;
        case 4:
        {
            self.typeLabel.text = @"好评";
            self.starView.rating = score;
        }
            break;
        case 5:
        {
            self.typeLabel.text = @"好评";
            self.starView.rating = score;
        }
            break;

            
        default:
        {
            self.typeLabel.text = @"暂无数据";
            self.starView.rating = 0;
        }
            break;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
